<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MenuDao
 *
 * @author Jorge
 */
class MenuDao {
    //put your code here
    private $conexion;
    
    public function __construct($conexion) {
        $this->conexion = $conexion;
    }
    
     public function getHijos($idPadre, $perfil){
        $sql = "SELECT m.menu_id, 
                       m.menu_nombre, 
                       m.menu_padre,
                       m.menu_vigente,
        			   m.menu_url
                FROM menu m
                INNER JOIN menu_perfil p ON p.perfil_id = ? and m.menu_id = p.menu_id
                WHERE m.menu_vigente = 'S' and m.menu_padre = ?";
        $consulta = $this->conexion->prepare($sql);        
        $consulta->execute(array($perfil, $idPadre));
        return $consulta->fetchAll();        
    }
    
//     public function tieneAcceso($perfil, $pagina) {
//     	$sql = "select 1 
//     			from menu m
// 				inner join menu_perfil mp on mp.perfil_id = ? and m.menu_id = mp.menu_id
// 				where m.menu_url like ?";
//     	$consulta = $this->conexion->prepare($sql);
//     	$result = $consulta->execute(array($perfil,'%' . $pagina . '%'));
//     	if($result) {
//     		if ($consulta->rowCount() > 0){
//     			return true;
//     		}	
//     	}    	
//         return false; 
//     }
        
}
